<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@page contentType="text/html;charset=utf-8" isELIgnored="false" %>
<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
  <title>文档列表 - 光年(Light Year Admin)后台管理系统模板</title>
  <link rel="icon" href="${base}/favicon.ico" type="image/ico">
  <meta name="keywords" content="LightYear,光年,后台模板,后台管理系统,光年HTML模板">
  <meta name="description" content="LightYear是一个基于Bootstrap v3.3.7的后台管理系统的HTML模板。">
  <meta name="author" content="yinqi">
  <link href="${base}/css/bootstrap.min.css" rel="stylesheet">
  <link href="${base}/css/materialdesignicons.min.css" rel="stylesheet">
  <link href="${base}/css/style.min.css" rel="stylesheet">
  <link href="${base}/css/animate.css" rel="stylesheet">
</head>

<body>
<div class="container-fluid">

  <div class="row">
    <div class="col-lg-12">
      <div class="card">
        <div class="card-body">
          <label style="font-size: 30px">管理评论</label>
          <form class="form-inline" action="${base}/postComments/search" target="mainView" method="post">
            <div class="form-group">
              <input class="form-control" type="text" id="example-if-password" name="str" placeholder="内容">
            </div>
            <div class="form-group">
              <button class="btn btn-default" type="submit">搜索</button>
            </div>
          </form>
          <form action="${base}/postComments/delAll" method="post" target="mainView" onsubmit="return check()">
            <div class="toolbar-btn-action">
              <button class="btn btn-danger"  href="#!"><i class="mdi mdi-window-close"></i>批量删除</button>
            </div>
            <div class="table-responsive">
              <table class="table table-bordered">
                <thead>
                <tr>
                  <th>
                    <label class="lyear-checkbox checkbox-primary">
                      <input type="checkbox" id="check-all"><span></span>
                    </label>
                  </th>
                  <th>帖子</th>
                  <th>评论</th>
                  <th>评论人</th>
                  <th>评论时间</th>
                  <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach var="p" items="${p.list}">
                  <tr>
                    <td>
                      <label class="lyear-checkbox checkbox-primary">
                        <input class="ids" type="checkbox" name="ids" value="${p.id}"><span></span>
                      </label>
                    </td>
                    <td>
                      <a style="color:black;" class="btn btn-xs btn-default" title="查看评论来源" href="${base}/post/lookPost?id=${p.post.id}" data-toggle="tooltip" target="mainView">
                        <c:if test="${fn:length(p.post.title)>10}">
                          ${fn:substring(p.post.title,0,10)}...
                        </c:if>
                        <c:if test="${fn:length(p.post.title)<=10}">
                          ${p.post.title}
                        </c:if>
                      </a>
                    </td>
                    <td>${p.content}</td>
                    <td>${p.user.name}</td>
                    <td><fmt:formatDate value="${p.time}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate></td>
                    <td>
                      <div class="btn-group">
                        <a class="btn btn-xs btn-default" onclick="return confirm('确认删除?') " href="${base}/postComments/del?id=${p.id}" title="删除" data-toggle="tooltip" target="mainView"><i class="mdi mdi-window-close"></i></a>
                      </div>
                    </td>
                  </tr>
                </c:forEach>
                </tbody>
              </table>
            </div>
          </form>
          <ul class="pagination">
            <li><span><a href="${base}/postComments/show?pageNum=${p.prePage}">«</a></span></li>
            <c:forEach var="i" items="${p.navigatepageNums}">
              <li <c:if test="${i eq p.pageNum}">class="active"</c:if>>
                <a href="${base}/postComments/show?pageNum=${i}">${i}</a>
              </li>
            </c:forEach>
            <li><span><a href="${base}/postComments/show?pageNum=${p.nextPage}">»</a></span></li>
          </ul>

        </div>
      </div>
    </div>

  </div>

</div>

<script type="text/javascript" src="${base}/js/jquery.min.js"></script>
<script type="text/javascript" src="${base}/js/bootstrap.min.js"></script>
<script type="text/javascript" src="${base}/js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="${base}/js/main.min.js"></script>

<!--消息提示-->
<script  src="${base}/js/bootstrap-notify.min.js"></script>
<script type="text/javascript" src="${base}/js/lightyear.js"></script>
<script type="text/javascript" src="${base}/js/main.min.js"></script>

<script type="text/javascript">
  function check() {
    var check=false;
    var ids=document.getElementsByName("ids");
    for(let i=0;i<ids.length;i++){
      if (ids[i].checked){
        check=confirm("是否删除选中帖子");
        if(check){
          return true;
        }else {
          return false;
        }
      }
    }
    return false;
  }

  $(function(){
    $('.search-bar .dropdown-menu a').click(function() {
      var field = $(this).data('field') || '';
      $('#search-field').val(field);
      $('#search-btn').html($(this).text() + ' <span class="caret"></span>');
    });
  });
</script>
</body>
</html>